package cn.edu.scau.cmi.mengzhuorong.singleton;

import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;

public class singletonController {
	@FXML
	private Button btn_single,btn_multiple;
	@FXML
	private TextField text_single,text_multiple;
	@FXML
	private Label label_single,label_multiple;
	
	public String ChairmanInfo;
	public String MarshalInfo;
	
	public Chairman chairman;
	public Marshal marshal;
	
	public void singlebutton() {
		String text = text_single.getText();
		chairman = Chairman.getInstance(text);
		if(ChairmanInfo==null) ChairmanInfo = chairman.getName() + chairman + '\n';
		else ChairmanInfo = ChairmanInfo + chairman.getName() + chairman + '\n';
        //System.out.println("good");
		label_single.setText(ChairmanInfo);
	}
	
	public void multipleButton() {
		String text = text_multiple.getText();
		marshal = Marshal.getInstance(text);
		if(marshal!=null) {
			if(MarshalInfo == null) MarshalInfo = marshal.getName() + marshal +'\n';
			else MarshalInfo = MarshalInfo + marshal.getName() + marshal + '\n';
			//System.out.println("bad");
			label_multiple.setText(MarshalInfo);
		}
		if(marshal == null) label_multiple.setText(MarshalInfo + "已经不能在创建了！");
	}
}
